package com.tanhua.app.controller;

import com.tanhua.app.controllerservice.QuestionnaireService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
public class QuestionnaireController {

    @Autowired
    private QuestionnaireService questionnaireService;

    @GetMapping(value = "/testSoul",name = "测灵魂-问卷列表")
    public ResponseEntity soulQuestion(){
        return questionnaireService.findQuestionnaire();
    }

    @PostMapping(value = "/testSoul",name = "测灵魂-提交问卷")
    public ResponseEntity submitQuestionnaire(@RequestBody Map<String,List> map){
        List list = map.get("answers");
        return questionnaireService.findReportId(list);
    }

    @GetMapping(value = "/testSoul/report/{id}",name = "测灵魂-查看结果")
    public ResponseEntity viewResult(@PathVariable("id") String id){
        return questionnaireService.viewResult(id);
    }
}
